﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using IGolovkine.AoA.Tcp;
using System.Threading;
using IGolovkine.AoA.Tcp.Channels.Http;

namespace IGolovkine.AoA.Tests
{
    [TestClass]
    public class HttpTunnelTests
    {
        [TestMethod]
        public void HttpTunnelAcidTest()
        {
            Random rnd = new Random();
            int port = rnd.Next(32000, 50000);
            string url = string.Format("http://localhost:{0}/", port);
            HttpChannelClient client = new HttpChannelClient(new HttpChannelClientConfiguration() { ServerUrl = url });

            HttpChannelServer server = new HttpChannelServer(new HttpChannelServerConfiguration(new string[] { url }));
            try
            {
                TunnelAcidTest acidTest = new TunnelAcidTest(TimeSpan.FromSeconds(1), client, server);

                acidTest.Run();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Thread.Sleep(1000);
                client.Dispose();
                server.Dispose();
            }
        }
    }
}
